﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace gamecontrol
{
    abstract public class InputBase
    {
        // club's position data
        protected double delta;
        protected double extend;
        protected FrameworkElement iElement;

        public virtual void handle()
        {
            Canvas.SetLeft(iElement, delta);
        }

        public abstract void handleOnLoaded(object sender, EventArgs e);

        protected InputBase(FrameworkElement elem)
        {
            iElement = elem;
        }

        public void onSizeChanged(Size dimensions)
        {
            extend = dimensions.Width - iElement.Width;
            delta = extend / 2.0;
            Canvas.SetLeft(iElement, delta);
            Canvas.SetTop(iElement, dimensions.Height - iElement.Height);
        }

        protected void calculateDelta(int value)
        {
            delta += value;

            if (delta < 0)
                delta = 0;
            if (delta > extend)
                delta = extend;
        }
    }
}
